

const objectToString = Object.prototype.toString
const toTypeString = (value: unknown): string => objectToString.call(value)
const hasOwnProperty = Object.prototype.hasOwnProperty

export const isPlainObject = (val: unknown): val is Record<string, any> =>
	toTypeString(val) === '[object Object]'
export const { isArray } = Array
export const isObject = (x: unknown): x is Object => typeof x === 'object'
export const isFunction = (x: unknown): x is Function => typeof x === 'function'
export const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'
export const hasOwn = (
	val: object,
	key: string | symbol | number
): key is keyof typeof val => hasOwnProperty.call(val, key)
